import React, { Component } from 'react';
class Demo extends Component {
  state={
    text:"🍉",
  }
 handerClick=(params) => {
   this.props.handerFatherC(this.state.text)
 }
  render(){
    return (
      <div>
        <h1>我是Dome组件</h1>
       {this.props.children}
       <button onClick = {this.handerClick}>传值给text</button>
      </div>
    )
  }
}
class DemoChilder extends Component {
  render(){
    return(
      <h2>我是Demo的childer</h2>
    )
  }
}
class Text extends Component {
  render(){
    return(
      <div>
      <h1>我是Text组件</h1>
      <h1>收到Demo传来的值{this.props.msg}</h1>
    </div>
    )
  }
}
class App extends Component {
  handerFatherC = (params) => {
    this.setState({
      text:params,
    })
  }
  state = {
    text:""
  }
  render() {
    return (
      <div>
         <Demo handerFatherC = {this.handerFatherC}>
           <DemoChilder></DemoChilder>
         </Demo>
         <Text msg={this.state.text}></Text>
      </div>
    );
  }
}

export default App;
